package com.winchain.chainbill.serfee.rx;

import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.ChainBillUtil;
import com.winchain.chainbill.serfee.service.impl.ServiceFeeAttService;
import com.winchain.chainbill.tbill.base.po.TbDct;
import com.winchain.chainbill.tbill.base.po.TbRec;
import com.winchain.chainbill.tbill.biz.TBill;
import com.winchain.chainbill.tbill.biz.TBillEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TBillDctReAprvSignDebitCertSubscriber extends OnErrorNotImplementedSubscriber<TBillEvent<TbDct>> {
	@Autowired
	private ServiceFeeAttService serviceFeeAttService;

	public void onApplicationEvent(TBillEvent<TbDct> t) {
		TbDct dct = (TbDct) t.getBill().getSource();
		this.serviceFeeAttService.genDebitCert(dct.getDctId(), "1");
		if (ChainBillUtil.onCfca()) {
			TbRec rec = t.getBill().getRec();
			this.serviceFeeAttService.signDebitCert(rec.getBillId(), dct.getFinId(), dct.getFinNm(), dct.getDctId(),
					"1");
		}
	}
}
